package com.asset.dispoal.company.service.commom;

import com.asset.dispoal.company.domain.db.entity.SysCompanyDo;
import com.asset.dispoal.company.domain.db.mapper.SysCompanyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tech.mhuang.pacebox.core.date.DateTimeUtil;
import tech.mhuang.pacebox.core.ddd.BaseCommand;
import tech.mhuang.pacebox.springboot.core.local.GlobalHeaderThreadLocal;
import tech.mhuang.pacebox.springboot.protocol.Result;

/**
 * @author qr
 * @date 2022/1/25$
 */
@Component
public class DeleteCommand implements BaseCommand<String, Result> {

    @Autowired
    SysCompanyMapper companyMapper;


    @Override
    public Result execute(String id) {
        SysCompanyDo companyDo = new SysCompanyDo();
        companyDo.setId(id);
        companyDo.setDelFlag("1");
        companyDo.setUpdateTime(DateTimeUtil.currentDate());
        companyDo.setUpdateUser(GlobalHeaderThreadLocal.getOrException().getUserId());
        companyMapper.update(companyDo);
        return Result.ok();
    }
}
